package com.bwie.controller;

import com.bwie.pojo.R;
import com.bwie.pojo.TbItemCat;
import com.bwie.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DarkClown
 * @date 2024-07-25 11:39
 * @project_name hight5
 * @parem
 **/
@RestController
@RequestMapping("/itm/itm")
public class ItemController {
    @Autowired
    ItemService itemService;



    @RequestMapping("/treeList")
    private R treeList(){


        return itemService.treeList2();
    }

    @RequestMapping("/treeList2")
    private R treeList2(){
        return itemService.treeList2();
    }

    //添加Item
    @RequestMapping("/addItem")
    private R addItem(@RequestBody TbItemCat tbItemCat){
        if (tbItemCat.getParentId()==null){
            tbItemCat.setParentId(0);
        }
        tbItemCat.setTypeId(35);
        itemService.save(tbItemCat);
        return R.ok();
    }

    //删除
    @RequestMapping("/delItem/{id}")
    private R delItem(@PathVariable("id") Integer id){

        return itemService.delId(id);
    }
}
